<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Pointer Arrays</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-data-types.html" title="GLib Data Types">
<link rel="prev" href="glib-Arrays.html" title="Arrays">
<link rel="next" href="glib-Byte-Arrays.html" title="Byte Arrays">
<meta name="generator" content="GTK-Doc V1.15 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Arrays.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-Byte-Arrays.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#glib-Pointer-Arrays.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#glib-Pointer-Arrays.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry" title="Pointer Arrays">
<a name="glib-Pointer-Arrays"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-Pointer-Arrays.top_of_page"></a>Pointer Arrays</span></h2>
<p>Pointer Arrays — arrays of pointers to any type of data, which
                    grow automatically as new elements are added</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv" title="Synopsis">
<a name="glib-Pointer-Arrays.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;glib.h&gt;

                    <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray">GPtrArray</a>;
<a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="returnvalue">GPtrArray</span></a>*          <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-new" title="g_ptr_array_new ()">g_ptr_array_new</a>                     (<em class="parameter"><code><span class="type">void</span></code></em>);
<a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="returnvalue">GPtrArray</span></a>*          <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-sized-new" title="g_ptr_array_sized_new ()">g_ptr_array_sized_new</a>               (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> reserved_size</code></em>);
<a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="returnvalue">GPtrArray</span></a>*          <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-new-with-free-func" title="g_ptr_array_new_with_free_func ()">g_ptr_array_new_with_free_func</a>      (<em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> element_free_func</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-set-free-func" title="g_ptr_array_set_free_func ()">g_ptr_array_set_free_func</a>           (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> element_free_func</code></em>);
<a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="returnvalue">GPtrArray</span></a>*          <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-ref" title="g_ptr_array_ref ()">g_ptr_array_ref</a>                     (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-unref" title="g_ptr_array_unref ()">g_ptr_array_unref</a>                   (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-add" title="g_ptr_array_add ()">g_ptr_array_add</a>                     (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-remove" title="g_ptr_array_remove ()">g_ptr_array_remove</a>                  (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-remove-index" title="g_ptr_array_remove_index ()">g_ptr_array_remove_index</a>            (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>);
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-remove-fast" title="g_ptr_array_remove_fast ()">g_ptr_array_remove_fast</a>             (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-remove-index-fast" title="g_ptr_array_remove_index_fast ()">g_ptr_array_remove_index_fast</a>       (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-remove-range" title="g_ptr_array_remove_range ()">g_ptr_array_remove_range</a>            (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> length</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-sort" title="g_ptr_array_sort ()">g_ptr_array_sort</a>                    (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> compare_func</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-sort-with-data" title="g_ptr_array_sort_with_data ()">g_ptr_array_sort_with_data</a>          (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> compare_func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-set-size" title="g_ptr_array_set_size ()">g_ptr_array_set_size</a>                (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> length</code></em>);
#define             <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-index" title="g_ptr_array_index()">g_ptr_array_index</a>                   (array,
                                                         index_)
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>*           <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-free" title="g_ptr_array_free ()">g_ptr_array_free</a>                    (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> free_seg</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-foreach" title="g_ptr_array_foreach ()">g_ptr_array_foreach</a>                 (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GFunc" title="GFunc ()"><span class="type">GFunc</span></a> func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
</pre>
</div>
<div class="refsect1" title="Description">
<a name="glib-Pointer-Arrays.description"></a><h2>Description</h2>
<p>
Pointer Arrays are similar to Arrays but are used only for storing
pointers.
</p>
<p>
</p>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>If you remove elements from the array, elements at the
end of the array are moved into the space previously occupied by the
removed element. This means that you should not rely on the index of
particular elements remaining the same. You should also be careful
when deleting elements while iterating over the array.</p>
</div>
<p>
</p>
<p>
To create a pointer array, use <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-new" title="g_ptr_array_new ()"><code class="function">g_ptr_array_new()</code></a>.
</p>
<p>
To add elements to a pointer array, use <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-add" title="g_ptr_array_add ()"><code class="function">g_ptr_array_add()</code></a>.
</p>
<p>
To remove elements from a pointer array, use <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-remove" title="g_ptr_array_remove ()"><code class="function">g_ptr_array_remove()</code></a>,
<a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-remove-index" title="g_ptr_array_remove_index ()"><code class="function">g_ptr_array_remove_index()</code></a> or <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-remove-index-fast" title="g_ptr_array_remove_index_fast ()"><code class="function">g_ptr_array_remove_index_fast()</code></a>.
</p>
<p>
To access an element of a pointer array, use <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-index" title="g_ptr_array_index()"><code class="function">g_ptr_array_index()</code></a>.
</p>
<p>
To set the size of a pointer array, use <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-set-size" title="g_ptr_array_set_size ()"><code class="function">g_ptr_array_set_size()</code></a>.
</p>
<p>
To free a pointer array, use <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-free" title="g_ptr_array_free ()"><code class="function">g_ptr_array_free()</code></a>.
</p>
<p>
</p>
<div class="example">
<a name="id954263"></a><p class="title"><b>Example 21. Using a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a></b></p>
<div class="example-contents">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="usertype">GPtrArray</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">gparray</span><span class="symbol">;</span>
<span class="usertype">gchar</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">string1 </span><span class="symbol">=</span><span class="normal"> </span><span class="string">"one"</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">string2 </span><span class="symbol">=</span><span class="normal"> </span><span class="string">"two"</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">string3 </span><span class="symbol">=</span><span class="normal"> </span><span class="string">"three"</span><span class="symbol">;</span>

<span class="normal">gparray </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Pointer-Arrays.html#g-ptr-array-new">g_ptr_array_new</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="function"><a href="glib-Pointer-Arrays.html#g-ptr-array-add">g_ptr_array_add</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">gparray</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a></span><span class="symbol">)</span><span class="normal"> string1</span><span class="symbol">);</span>
<span class="function"><a href="glib-Pointer-Arrays.html#g-ptr-array-add">g_ptr_array_add</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">gparray</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a></span><span class="symbol">)</span><span class="normal"> string2</span><span class="symbol">);</span>
<span class="function"><a href="glib-Pointer-Arrays.html#g-ptr-array-add">g_ptr_array_add</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">gparray</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a></span><span class="symbol">)</span><span class="normal"> string3</span><span class="symbol">);</span>

<span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="glib-Pointer-Arrays.html#g-ptr-array-index">g_ptr_array_index</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">gparray</span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">!=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a></span><span class="symbol">)</span><span class="normal"> string1</span><span class="symbol">)</span>
<span class="normal">  </span><span class="function"><a href="glib-Warnings-and-Assertions.html#g-print">g_print</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"ERROR: got %p instead of %p</span><span class="specialchar">\n</span><span class="string">"</span><span class="symbol">,</span>
<span class="normal">           </span><span class="function"><a href="glib-Pointer-Arrays.html#g-ptr-array-index">g_ptr_array_index</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">gparray</span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">),</span><span class="normal"> string1</span><span class="symbol">);</span>

<span class="function"><a href="glib-Pointer-Arrays.html#g-ptr-array-free">g_ptr_array_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">gparray</span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#TRUE:CAPS">TRUE</a></span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

</div>
<p><br class="example-break">
</p>
</div>
<div class="refsect1" title="Details">
<a name="glib-Pointer-Arrays.details"></a><h2>Details</h2>
<div class="refsect2" title="GPtrArray">
<a name="GPtrArray"></a><h3>GPtrArray</h3>
<pre class="programlisting">typedef struct {
  gpointer *pdata;
  guint	    len;
} GPtrArray;
</pre>
<p>
Contains the public fields of a pointer array.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> *<em class="structfield"><code><a name="GPtrArray.pdata"></a>pdata</code></em>;</span></p></td>
<td>points to the array of pointers, which may be moved when the
        array grows.
</td>
</tr>
<tr>
<td><p><span class="term"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> <em class="structfield"><code><a name="GPtrArray.len"></a>len</code></em>;</span></p></td>
<td>number of pointers in the array.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_new ()">
<a name="g-ptr-array-new"></a><h3>g_ptr_array_new ()</h3>
<pre class="programlisting"><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="returnvalue">GPtrArray</span></a>*          g_ptr_array_new                     (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Creates a new <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> with a reference count of 1.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the new <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_sized_new ()">
<a name="g-ptr-array-sized-new"></a><h3>g_ptr_array_sized_new ()</h3>
<pre class="programlisting"><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="returnvalue">GPtrArray</span></a>*          g_ptr_array_sized_new               (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> reserved_size</code></em>);</pre>
<p>
Creates a new <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> with <em class="parameter"><code>reserved_size</code></em> pointers preallocated
and a reference count of 1. This avoids frequent reallocation, if
you are going to add many pointers to the array. Note however that
the size of the array is still 0.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reserved_size</code></em> :</span></p></td>
<td>number of pointers preallocated.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the new <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_new_with_free_func ()">
<a name="g-ptr-array-new-with-free-func"></a><h3>g_ptr_array_new_with_free_func ()</h3>
<pre class="programlisting"><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="returnvalue">GPtrArray</span></a>*          g_ptr_array_new_with_free_func      (<em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> element_free_func</code></em>);</pre>
<p>
Creates a new <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> with a reference count of 1 and use <em class="parameter"><code>element_free_func</code></em>
for freeing each element when the array is destroyed either via
<a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-unref" title="g_ptr_array_unref ()"><code class="function">g_ptr_array_unref()</code></a>, when <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-free" title="g_ptr_array_free ()"><code class="function">g_ptr_array_free()</code></a> is called with <em class="parameter"><code>free_segment</code></em>
set to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> or when removing elements.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>element_free_func</code></em> :</span></p></td>
<td>A function to free elements with destroy <em class="parameter"><code>array</code></em> or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> A new <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_set_free_func ()">
<a name="g-ptr-array-set-free-func"></a><h3>g_ptr_array_set_free_func ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_ptr_array_set_free_func           (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> element_free_func</code></em>);</pre>
<p>
Sets a function for freeing each element when <em class="parameter"><code>array</code></em> is destroyed
either via <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-unref" title="g_ptr_array_unref ()"><code class="function">g_ptr_array_unref()</code></a>, when <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-free" title="g_ptr_array_free ()"><code class="function">g_ptr_array_free()</code></a> is called
with <em class="parameter"><code>free_segment</code></em> set to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> or when removing elements.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>A <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>element_free_func</code></em> :</span></p></td>
<td>A function to free elements with destroy <em class="parameter"><code>array</code></em> or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_ref ()">
<a name="g-ptr-array-ref"></a><h3>g_ptr_array_ref ()</h3>
<pre class="programlisting"><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="returnvalue">GPtrArray</span></a>*          g_ptr_array_ref                     (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>);</pre>
<p>
Atomically increments the reference count of <em class="parameter"><code>array</code></em> by one. This
function is MT-safe and may be called from any thread.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>A <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> The passed in <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_unref ()">
<a name="g-ptr-array-unref"></a><h3>g_ptr_array_unref ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_ptr_array_unref                   (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>);</pre>
<p>
Atomically decrements the reference count of <em class="parameter"><code>array</code></em> by one. If the
reference count drops to 0, the effect is the same as calling
<a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-free" title="g_ptr_array_free ()"><code class="function">g_ptr_array_free()</code></a> with <em class="parameter"><code>free_segment</code></em> set to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>. This function
is MT-safe and may be called from any thread.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>A <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_add ()">
<a name="g-ptr-array-add"></a><h3>g_ptr_array_add ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_ptr_array_add                     (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<p>
Adds a pointer to the end of the pointer array. The array will grow
in size automatically if necessary.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>the pointer to add.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_remove ()">
<a name="g-ptr-array-remove"></a><h3>g_ptr_array_remove ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_ptr_array_remove                  (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<p>
Removes the first occurrence of the given pointer from the pointer
array. The following elements are moved down one place. If <em class="parameter"><code>array</code></em>
has a non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> <a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> function it is called for the
removed element.
</p>
<p>
It returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the pointer was removed, or <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> if the
pointer was not found.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>the pointer to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the pointer is removed. <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> if the pointer is
          not found in the array.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_remove_index ()">
<a name="g-ptr-array-remove-index"></a><h3>g_ptr_array_remove_index ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            g_ptr_array_remove_index            (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>);</pre>
<p>
Removes the pointer at the given index from the pointer array. The
following elements are moved down one place. If <em class="parameter"><code>array</code></em> has a
non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> <a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> function it is called for the removed
element.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em> :</span></p></td>
<td>the index of the pointer to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the pointer which was removed.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_remove_fast ()">
<a name="g-ptr-array-remove-fast"></a><h3>g_ptr_array_remove_fast ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_ptr_array_remove_fast             (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<p>
Removes the first occurrence of the given pointer from the pointer
array. The last element in the array is used to fill in the space,
so this function does not preserve the order of the array. But it is
faster than <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-remove" title="g_ptr_array_remove ()"><code class="function">g_ptr_array_remove()</code></a>. If <em class="parameter"><code>array</code></em> has a non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>
<a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> function it is called for the removed element.
</p>
<p>
It returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the pointer was removed, or <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> if the
pointer was not found.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>the pointer to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the pointer was found in the array.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_remove_index_fast ()">
<a name="g-ptr-array-remove-index-fast"></a><h3>g_ptr_array_remove_index_fast ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            g_ptr_array_remove_index_fast       (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>);</pre>
<p>
Removes the pointer at the given index from the pointer array. The
last element in the array is used to fill in the space, so this
function does not preserve the order of the array. But it is faster
than <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-remove-index" title="g_ptr_array_remove_index ()"><code class="function">g_ptr_array_remove_index()</code></a>. If <em class="parameter"><code>array</code></em> has a non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>
<a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> function it is called for the removed element.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em> :</span></p></td>
<td>the index of the pointer to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the pointer which was removed.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_remove_range ()">
<a name="g-ptr-array-remove-range"></a><h3>g_ptr_array_remove_range ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_ptr_array_remove_range            (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> length</code></em>);</pre>
<p>
Removes the given number of pointers starting at the given index
from a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.  The following elements are moved to close the
gap. If <em class="parameter"><code>array</code></em> has a non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> <a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> function it is called
for the removed elements.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <em class="parameter"><code>GPtrArray</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em> :</span></p></td>
<td>the index of the first pointer to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
<td>the number of pointers to remove.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_sort ()">
<a name="g-ptr-array-sort"></a><h3>g_ptr_array_sort ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_ptr_array_sort                    (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> compare_func</code></em>);</pre>
<p>
Sorts the array, using <em class="parameter"><code>compare_func</code></em> which should be a <code class="function">qsort()</code>-style
comparison function (returns less than zero for first arg is less
than second arg, zero for equal, greater than zero if irst arg is
greater than second arg).
</p>
<p>
If two array elements compare equal, their order in the sorted array
is undefined.
</p>
<p>
</p>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>The comparison function for <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-sort" title="g_ptr_array_sort ()"><code class="function">g_ptr_array_sort()</code></a> doesn't
take the pointers from the array as arguments, it takes pointers to
the pointers in the array.</p>
</div>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></p></td>
<td>comparison function.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_sort_with_data ()">
<a name="g-ptr-array-sort-with-data"></a><h3>g_ptr_array_sort_with_data ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_ptr_array_sort_with_data          (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> compare_func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>
Like <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-sort" title="g_ptr_array_sort ()"><code class="function">g_ptr_array_sort()</code></a>, but the comparison function has an extra
user data argument.
</p>
<p>
</p>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>The comparison function for <a class="link" href="glib-Pointer-Arrays.html#g-ptr-array-sort-with-data" title="g_ptr_array_sort_with_data ()"><code class="function">g_ptr_array_sort_with_data()</code></a>
doesn't take the pointers from the array as arguments, it takes
pointers to the pointers in the array.</p>
</div>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></p></td>
<td>comparison function.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>data to pass to <em class="parameter"><code>compare_func</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_set_size ()">
<a name="g-ptr-array-set-size"></a><h3>g_ptr_array_set_size ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_ptr_array_set_size                (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> length</code></em>);</pre>
<p>
Sets the size of the array. When making the array larger,
newly-added elements will be set to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. When making it smaller,
if <em class="parameter"><code>array</code></em> has a non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> <a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> function then it will be
called for the removed elements.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
<td>the new length of the pointer array.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_index()">
<a name="g-ptr-array-index"></a><h3>g_ptr_array_index()</h3>
<pre class="programlisting">#define             g_ptr_array_index(array,index_)</pre>
<p>
Returns the pointer at the given index of the pointer array.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em> :</span></p></td>
<td>the index of the pointer to return.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the pointer at the given index.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_free ()">
<a name="g-ptr-array-free"></a><h3>g_ptr_array_free ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>*           g_ptr_array_free                    (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> free_seg</code></em>);</pre>
<p>
Frees the memory allocated for the <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>. If <em class="parameter"><code>free_seg</code></em> is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>
it frees the memory block holding the elements as well. Pass <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>
if you want to free the <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> wrapper but preserve the
underlying array for use elsewhere. If the reference count of <em class="parameter"><code>array</code></em>
is greater than one, the <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> wrapper is preserved but the
size of <em class="parameter"><code>array</code></em> will be set to zero.
</p>
<p>
</p>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>If array contents point to dynamically-allocated
memory, they should be freed separately if <em class="parameter"><code>free_seg</code></em> is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> and no
<a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> function has been set for <em class="parameter"><code>array</code></em>.</p>
</div>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>free_seg</code></em> :</span></p></td>
<td>if <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> the actual pointer array is freed as well.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the pointer array if <em class="parameter"><code>free_seg</code></em> is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, otherwise <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
          The pointer array should be freed using <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" title="g_ptr_array_foreach ()">
<a name="g-ptr-array-foreach"></a><h3>g_ptr_array_foreach ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_ptr_array_foreach                 (<em class="parameter"><code><a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GFunc" title="GFunc ()"><span class="type">GFunc</span></a> func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>
Calls a function for each element of a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Pointer-Arrays.html#GPtrArray" title="GPtrArray"><span class="type">GPtrArray</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
<td>the function to call for each array element
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>user data to pass to the function
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.15</div>
</body>
</html>